package org.dslintegration.history;

import org.dslintegration.merge.km3.core.ModelElement;

public class MergeAction {
	protected EMergeActionType type;
	protected String output;

	public MergeAction(EMergeActionType type, String output) {
		super();
		this.type = type;
		this.output = output;
	}

	public static MergeAction getChange(ModelElement source, ModelElement target) {
		String output = "changing from type " + EMetamodelSource.OUTPUT + " , " + source.getClass().getSimpleName() + ":" + source.getQName();
		output += " to " + EMetamodelSource.OUTPUT + " , " + target.getClass().getSimpleName() + ":" + target.getQName();
		return new MergeAction(EMergeActionType.CHANGE, output);
	}

	public static MergeAction getAdd(ModelElement source) {
		String output = "adding to " + EMetamodelSource.OUTPUT + " , " + source.getClass().getSimpleName() + ":" + source.getQName();
		return new MergeAction(EMergeActionType.ADD, output);
	}

	public static MergeAction getDelete(ModelElement source) {
		String output = "removing " + EMetamodelSource.OUTPUT + " , " + source.getClass().getSimpleName() + ":" + source.getQName();
		return new MergeAction(EMergeActionType.REMOVE, output);
	}

	public static MergeAction getMerge(ModelElement source, ModelElement target) {
		String output = "merging " + EMetamodelSource.OUTPUT + " , " + source.getClass().getSimpleName() + ":" + source.getQName() + " with "
				+ EMetamodelSource.OUTPUT + " , " + target.getClass().getSimpleName() + ":" + target.getQName();
		return new MergeAction(EMergeActionType.MERGE, output);
	}

	public static MergeAction getCopy(EMetamodelSource sourceMM, ModelElement source, EMetamodelSource targetMM, ModelElement target) {
		String output = "copying from " + sourceMM + " , " + source.getClass().getSimpleName() + ":" + source.getQName() + " to " + targetMM + " , "
				+ source.getClass().getSimpleName() + ":" + target.getQName();
		return new MergeAction(EMergeActionType.COPY, output);
	}

	public String toString() {
		return type + "\t\t" + output;
	}
}
